package com.bestvike.portal.controller;

import com.bestvike.portal.data.SysDept;
import com.bestvike.portal.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SysDeptController extends BaseController {
    @Autowired
    private SysDeptService sysDeptService;

    @GetMapping("/api/departments")
    public List<SysDept> fetchTree() {
        return sysDeptService.fetchTree();
    }

    @PostMapping("/api/departments")
    public SysDept create(@RequestBody SysDept sysDept) {
        return sysDeptService.create(sysDept);
    }

    @PutMapping("/api/departments")
    public int modify(@RequestBody SysDept sysDept) {
        return sysDeptService.modify(sysDept);
    }

    @DeleteMapping("/api/departments/{ids}")
    public int remove(@PathVariable String ids) {
        return sysDeptService.remove(ids);
    }
}
